/*
 * ---------------------------------------------------------------------
 * Copyright (c) 2014, 2015 All Right Reserved
 * This software is developed for study and improve coding skill ...
 *
 * Project:  Excellent Coding< EC >
 *
 * ecString.h
 * This file for EC project common string interface define.
 *
 * Eamil:   epengao@126.com
 * Author:  Peter Gao
 * Version: Intial first version.
 * --------------------------------------------------------------------
 */

#ifndef EC_STRING_H
#define EC_STRING_H

#include "ecBaseType.h"

namespace ec {

class ecString
{
public:
    ecString();
    ~ecString();
    ecString(const EC_PCHAR pStr);
    ecString(const ecString &rString);
    ecString(const EC_PCHAR pStr, EC_U32 nSize);
    ecString(const ecString &rString, EC_U32 nSize);

    EC_U32 Trim();
    EC_U32 TrimEnd();
    EC_U32 Length() const;
    EC_BOOL IsNull() const;
    const EC_PCHAR GetAddr() const;
    EC_CHAR& operator[](EC_U32 nPos);
    EC_S32 FindChar(const EC_CHAR cChar) const;
    const EC_CHAR& operator[](EC_U32 nPos) const;
    ecString& operator=(const EC_PCHAR pStr);
    ecString& operator+(const EC_PCHAR pStr);
    ecString& operator=(const ecString &rString);
    ecString& operator+(const ecString &rString);

public:
    friend EC_BOOL operator <(const ecString &st1, const ecString &st2);
    friend EC_BOOL operator >(const ecString &st1, const ecString &st2);
    friend EC_BOOL operator<=(const ecString &st1, const ecString &st2);
    friend EC_BOOL operator>=(const ecString &st1, const ecString &st2);
    friend EC_BOOL operator==(const ecString &st1, const ecString &st2);

private:
    EC_PCHAR m_pStr;
    EC_U32   m_nSize;
};

} /* namespace ec */
#endif /* EC_STRING_H   */